#ifndef __REDISRESULT_H__
#define __REDISRESULT_H__
#include <functional>
#include <vector>
#include <string>
#include <hiredis/hiredis.h>

struct redisReply;
enum class RedisResultType : int
{
    kInteger = 0,
    kString,
    kArray,
    kStatus,
    kNil,
    kError
};

class RedisResult
{
  public:
    explicit RedisResult(redisReply *result) : result_(result)
    {
    }
    ~RedisResult() = default;

    RedisResultType type() const noexcept;

    std::string asString() const noexcept(false);

    std::vector<RedisResult> asArray() const noexcept(false);

    long long asInteger() const noexcept(false);

    std::string getStringForDisplaying() const noexcept;

    std::string getStringForDisplayingWithIndent(
        size_t indent = 0) const noexcept;

    bool isNil() const noexcept;

    operator bool() const
    {
        return !isNil();
    }

  private:
    redisReply *result_;
};

using RedisResultCallback_t = std::function<void(const RedisResult &)>;

#endif  // __REDISRESULT_H__